<?php
    session_start();

    $email = stripslashes($username);

    require 'phpincludes/dbconnect.php';
    $safeemail = mysql_real_escape_string($email);
    $query = "SELECT * FROM `".$tblusers."` WHERE `email` = '".$safeusername."'";
    $res = mysql_query($query);
    $row = mysql_fetch_assoc($res);
    mysql_close();

    if($row['id']){
        require 'phpclasses/userclass.php';
        $user = new userclass();
        $user->initwithuserid($_SESSION['id']);
    }

   if(isset($_GET['retpage']))
        $retpage = $_GET['retpage'];
    else
        $retpage = 'index.php';

    if(isset($_GET['showitem']) && $_GET['showitem'] != '')
        $returl = $retpage.'?showitem='.$_GET['showitem'];
    else
        $returl = $retpage;

    header('Location: '.$returl);
    exit();
?>